package com.ddpt.platform.common.util;

import com.ddpt.platform.common.exception.CommonException;
import com.ddpt.platform.common.exception.ErrorCodeDefinition;
import org.apache.commons.lang3.StringUtils;

/**
 * 断言
 */
public class AssertUtil {

    public static void isEmpty(String s,String errorMsg){
        if(StringUtils.isBlank(s)){
            throw new CommonException(errorMsg);
        }
    }

    public static void isEmpty(String s, ErrorCodeDefinition e){
        if(StringUtils.isBlank(s)){
            throw new CommonException(e);
        }
    }

    public static void isNull(Object object,String errorMsg){
        if(object == null){
            throw new CommonException(errorMsg);
        }
    }

    public static void isNull(Object object,ErrorCodeDefinition e){
        if(object == null){
            throw new CommonException(e);
        }
    }

    public static void isTrue(boolean boo,String errorMsg){
        if(boo){
            throw new CommonException(errorMsg);
        }
    }

    public static void isTrue(boolean boo, ErrorCodeDefinition e){
        if(boo){
            throw new CommonException(e);
        }
    }
}
